package com.hyt.it.ogt.ksmonitor.statistics.service.impl;

import com.hyt.it.ogt.ksmonitor.statistics.model.CandidateStatisticsAddVO;
import com.hyt.it.ogt.ksmonitor.statistics.mq.StatisticsProducer;
import com.hyt.it.ogt.ksmonitor.statistics.queue.StatisticsBlockQueue;
import com.hyt.it.ogt.ksmonitor.statistics.service.IMonitorStatisticsSubmitService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author 朱振宇
 * @since 2022/11/14
 */
@Component
@Slf4j
public class MonitorStatisticsSubmitServiceImpl implements IMonitorStatisticsSubmitService {

    @Resource
    private StatisticsProducer statisticsProducer;

    @Override
    public void sendAddNumMq(CandidateStatisticsAddVO candidateStatisticsAddVO) {
        statisticsProducer.sendMessage(candidateStatisticsAddVO);
    }

    @Override
    public void addNum(String examId, Integer statisticsType, String examCandidateId, boolean isRepeat, int num) {
        StatisticsBlockQueue.producer(CandidateStatisticsAddVO.builder()
                .examId(examId)
                .statisticsType(statisticsType)
                .candidateId(examCandidateId)
                .isRepeat(isRepeat)
                .num(num).build());
    }

    @Override
    public void addNum(String examId, String roomId, Integer statisticsType, String examCandidateId, boolean isRepeat, int num) {
        StatisticsBlockQueue.producer(CandidateStatisticsAddVO.builder()
                .examId(examId)
                .roomId(roomId)
                .statisticsType(statisticsType)
                .candidateId(examCandidateId)
                .isRepeat(isRepeat)
                .num(num).build());
    }

}
